package com.szbber.medical.ui.activity

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.library.baseAdapters.BR
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.orhanobut.logger.Logger
import com.szbber.commen.base.BaseActivity
import com.szbber.commen.base.BaseApplication
import com.szbber.commen.base.BaseRoutePath
import com.szbber.commen.base.BaseVMActivity
import com.szbber.commen.utils.PreferUtil
import com.szbber.commen.utils.dataStoreRead
import com.szbber.medical.R
import com.szbber.medical.databinding.ActivitySplashActivityBinding
import com.szbber.medical.viewmodel.SplashViewmodel
import com.szbber.medical.viewmodel.fragment.PortSettingViewModel
import java.util.concurrent.TimeUnit

class SplashActivity : BaseVMActivity<ActivitySplashActivityBinding,SplashViewmodel>() {

    override fun bindLayout(): Int = R.layout.activity_splash_activity

    override fun initView() {
        mBinding.vm = mViewModel
        mViewModel.deviceType.observe(this) { t ->
          when(t){
              0-> {
                startActivityIn(Intent(this, SettingActivity::class.java), this)
              }
              1-> {
                  open(BaseRoutePath.bed_home)
              }
              2-> {
                  open(BaseRoutePath.door_home)
              }
              4-> {
                  open(BaseRoutePath.board_home)
              }
          }
        }

    }

    override fun onResume() {
        super.onResume()
        mViewModel.getDeviceType(this)
    }

    override fun initVM(): SplashViewmodel =  ViewModelProvider(this, ViewModelProvider.NewInstanceFactory()).get(SplashViewmodel::class.java)




}